package com.googlecode.moneyManager.excelReader;

import com.googlecode.moneyManager.model.Currency;
import com.googlecode.moneyManager.reader.DataValueProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * Author: Sergiy Doroshenko
 * Date: Jul 19, 2010
 * Time: 4:14:40 PM
 */
@Repository
public class DataValueProviderExcelImpl implements DataValueProvider {

    private ExcelDocument excelDocument;

    public ExcelDocument getExcelDocument() {
        return excelDocument;
    }
    
    @Autowired
    public void setExcelDocument(ExcelDocument excelDocument) {
        this.excelDocument = excelDocument;
    }

    public String getSumAmount(Currency currency) {
        switch(currency){
            case USD: return excelDocument.getSheet(0).getRow(5).getCell(7).getRawValue();
            case UAH: return excelDocument.getSheet(0).getRow(4).getCell(7).getRawValue();
        }
        return null;
    }

    public String getPartAmount(Currency currency) {
        switch(currency){
            case USD: return excelDocument.getSheet(0).getRow(0).getCell(7).getRawValue();
            case UAH: return excelDocument.getSheet(0).getRow(2).getCell(7).getRawValue();
            case EUR: return excelDocument.getSheet(0).getRow(1).getCell(7).getRawValue();
        }
        return null;
    }
  
    public String getRate(Currency currency) {
        switch(currency){
            case USD: return excelDocument.getSheet(0).getRow(0).getCell(9).getRawValue();
            case EUR: return excelDocument.getSheet(0).getRow(1).getCell(9).getRawValue();
        }
        return null;
    }
}
